global:
  scrape_interval: 15s
  evaluation_interval: 15s

rule_files:
  - '/etc/prometheus/alerting/*'

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:{{ prometheus_port }}']
  - job_name: 'ceph'
    honor_labels: true
    static_configs:
{% for host in groups['mgrs'] | default(groups['mons']) %}
      - targets: ['{{ host }}:9283']
        labels:
          instance: 'ceph_cluster'
{% endfor %}
  - job_name: 'node'
    static_configs:
{% if grafana_server_group_name in groups %}
{% for host in (groups['all'] | difference(groups[grafana_server_group_name])) %}
      - targets: ['{{ host }}:{{ node_exporter_port }}']
        labels:
          instance: "{{ hostvars[host]['ansible_nodename'] }}"
{% endfor %}
  - job_name: 'grafana'
    static_configs:
{% for host in groups[grafana_server_group_name] %}
      - targets: ['{{ host }}:{{ node_exporter_port }}']
        labels:
          instance: "{{ hostvars[host]['ansible_nodename'] }}"
{% endfor %}
{% else %}
{% for host in groups['all'] %}
      - targets: ['{{ host }}:{{ node_exporter_port }}']
        labels:
          instance: "{{ hostvars[host]['ansible_nodename'] }}"
{% endfor %}
{% endif %}
{% if 'iscsigws' in groups %}
  - job_name: 'iscsi-gws'
    static_configs:
{% for host in groups['iscsigws'] %}
      - targets: ['{{ host }}:9287']
        labels:
          instance: "{{ hostvars[host]['ansible_nodename'] }}"
{% endfor %}
{% endif %}
alerting:
  alertmanagers:
  - scheme: http
    static_configs:
    - targets: ['{{ grafana_server_addr }}:{{ alertmanager_port }}']
